/*********************************************************************************
Organization 					: 				Georgia Institute of Technology
  
Institute 						:				Cognitive Computing Group(CCL)
 
Authors							: 				Santiago Ontanon, Kinshuk Mishra
 												Neha Sugandh 
 												
Class							:				WoodCondition
 
Function						: 				Provides a class for holding a 
												condition for wood
****************************************************************************/

package planninglanguage.conditions;

import mre.MRE;

import org.jdom.Element;

import util.XMLWriter;
import base.WargusGameState;


public class WoodCondition extends Condition {

	int m_minWood;
	
	public WoodCondition(int a_minWood) {
		m_minWood=a_minWood;
	}
	public String toString(int tabs)
	{
		String n = super.toString(tabs);
		n = n + "Min Wood needed is:" + m_minWood;
		return n;
	}
	
	public boolean test(WargusGameState a_gameState)
	{		
//		System.out.println("WoodCondition: test( wood = " + m_minWood + ")");	
		
		if (a_gameState.getPlayer().getWood()-MRE.allocated_wood >= m_minWood) return true;
		  																  else return false;			
	}
	
	public void writeXML(XMLWriter w) {
		w.tag("condition type=\""+this.getClass().getSimpleName()+"\"");
		{
			w.tag("min-wood", m_minWood);
		}
		w.tag("/condition");
	}
	
	protected static Condition loadConditionFromXML(Element e) {
		return new WoodCondition(Integer.parseInt(e.getChildText("min-wood")));
	}
}
